var $ = require("expose-loader?$!jquery");
require('lib/jquery.validate');

// 手机号码验证规则
$.validator.addMethod('isphone', function (value, element, param) {

	var reg = /^((13|14|15|17|18)[0-9]{1}\d{8})$/;

	return this.optional(element) || (reg.test(value));

}, '格式错误');


// 电话号码验证规则
$.validator.addMethod('istel', function (value, element, param) {

	var reg = /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}$/;

	return this.optional(element) || (reg.test(value));

}, '格式错误');


// 手机或者固定电话号码验证规则
$.validator.addMethod('iscontact', function (value, element, param) {

	var reg = /^((\d{3,4}-)|\d{3.4}-)?\d{7,8}|((13|14|15|17|18)[0-9]{1}\d{8})$/;

	return this.optional(element) || (reg.test(value));

}, '格式错误');


// 校验传真
$.validator.addMethod('isfax', function (value, element, param) {

	var reg = /^[+]{0,1}(\d){1,3}[ ]?([-]?((\d)|[ ]){1,12})+$/;

	return this.optional(element) || (reg.test(value));

}, '传真格式错误');

// 身份证格式
// var cP = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
$.validator.addMethod('isCP', function (value, element, param) {

	var reg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;

	return this.optional(element) || (reg.test(value));

}, '身份证格式错误');


// 6-20位字符，区分大小写
$.validator.addMethod('ispass', function (value, element, param) {

	var reg = /^[\x21-\x7E]{6,20}$/;

	return this.optional(element) || (reg.test(value));

}, '密码格式错误');


$.validator.addMethod("vaccount", function(value, element) {
    return this.optional(element) || (/^\w+$/.test(value));
}, "只能包含数字和英文");